import React, { Component } from 'react';
// 1. 引入请求 axios
import axios from "axios"
// 3. 引入 store
import store from "./store"
class App extends Component {

  componentDidMount(){
    // 2. 发请求 
    axios.get("http://s.linweiqin.com/api/s/loginCheck",{
      params:{
        username:"18988938574",
        password:123456
      }
    }).then(res=>{
      // console.log(res);
      // console.log(res.data.wdata.oauth_token);
      store.dispatch({
        type:"INIT_TOKEN",
        payload:{
          oauth_token:res.data.wdata.oauth_token
        }
      })
    })
  }
  render() {
    return (
      <div>
        <button onClick={()=>{
          console.log(store.getState());
        }}>获取token</button>
      </div>
    );
  }
}

export default App;
